package server

import (
	"conf"
	"github.com/gin-gonic/gin"
	"server/category"
	"server/news"
	"server/upload"
	"server/help"
)

func registerRouter(rg *gin.RouterGroup, config *conf.Config) {

	//uploadtoken
	up := upload.New(config)
	rg.GET("/upload/token",       up.GetToken)
	// news
	nw := news.New(config)
	rg.GET("/news",       nw.Get)
	rg.GET("/news/:id",   nw.Get)
	rg.PUT("/news/:id",   nw.Put)
	rg.DELETE("/news/:id",nw.Delete)
	rg.POST("/news",      nw.Post)

	// // kuaixun
	// rg.GET("/kuaixun",       kuaixun.Get)
	// rg.GET("/kuaixun/:id",   kuaixun.Get)
	// rg.PUT("/kuaixun/:id",   kuaixun.Put)
	// rg.DELETE("/kuaixun/:id",kuaixun.Delete)
	// rg.POST("/kuaixun",      kuaixun.Post)

	// category
	cate := category.New(config)
	rg.GET("/category",       cate.Get)
	rg.GET("/category/:id",   cate.Get)
	rg.PUT("/category/:id",   cate.Put)
	rg.DELETE("/category/:id",cate.Delete)
	rg.POST("/category",      cate.Post)
	// help
	hp  := help.New(config)
	rg.GET("/help",       hp.Get)
	rg.GET("/help/:id",   hp.Get)
	rg.PUT("/help/:id",   hp.Put)
	rg.DELETE("/help/:id",hp.Delete)
	rg.POST("/help",      hp.Post)
}